﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace spel
{
    //tom ska försöka fånga jerry
    class tom
    {
        public Vector2 Position;
        
        
        private Texture2D texture;
        private SpriteBatch spriteBatch;
        private Game1 game;
     
        private float SpeedX = 6;
        private float SpeedY = 4;

        public Rectangle GetRectangle()
        {
            Rectangle r = new Rectangle((int)Position.X, (int)Position.Y, texture.Width, texture.Height);
            return r;
        }

        public void Update(GameTime gameTime)
        {
            
                Position.X += SpeedX * 10 * gameTime.ElapsedGameTime.Milliseconds / 1000;
                Position.Y += SpeedY;
                if (Position.X > (game.GraphicsDevice.Viewport.Width-texture.Width))
                {
                    SpeedX *= -1;
                }

                if (Position.Y > (game.GraphicsDevice.Viewport.Height - texture.Height))
                {
                    SpeedY *= -1;
                }
                else if (Position.Y < 0)
                {
                    SpeedY *= -1;
                }

                else if (Position.X <= 0)
                {
                    SpeedX *= -1;
                }
               
            
          }
        public void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(texture, Position, Color.White);
            spriteBatch.End();
        }

        public tom(Game1 game, Texture2D texture, SpriteBatch spriteBatch)
        {
            Vector2 startpos = new Vector2(0, 0);
            this.spriteBatch = spriteBatch;
            this.texture = texture;
            this.game = game;
        }
    }
}
